extends Node


func transition(data: LevelData):
	var level_name = data.level_name
	var level_packed_scene = ResourceManager.get_resource(level_name) as PackedScene
	
	get_tree().current_scene.queue_free()
	var scene_inst:Node2D = level_packed_scene.instantiate()
	get_tree().root.add_child(scene_inst)
	get_tree().current_scene = scene_inst
	
	var current_level = get_tree().current_scene as Level
	if current_level.has_method("init_by_data"):
		current_level.init_by_data(data)
		

func transition_game_end():
	var level_name = "game_end_level"
	var level_packed_scene = ResourceManager.get_resource(level_name) as PackedScene
	
	get_tree().current_scene.queue_free()
	var scene_inst:Node2D = level_packed_scene.instantiate()
	get_tree().root.add_child(scene_inst)
	get_tree().current_scene = scene_inst
	

func transition_2(level_name: String):
	var level_packed_scene = ResourceManager.get_resource(level_name) as PackedScene
	
	get_tree().current_scene.queue_free()
	var scene_inst:Node2D = level_packed_scene.instantiate()
	get_tree().root.add_child(scene_inst)
	get_tree().current_scene = scene_inst
